﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;
using WebServicePI.Entidad;
using MySql.Data;
using MySql.Data.MySqlClient;
using System.Data;

namespace WebServicePI.Data
{
    public class DisciplinaData
    {
        MySqlConnectionPI cn = new MySqlConnectionPI();

        public Disciplina[] ListarDisciplinas()
        {

            try {
                MySqlDataAdapter da = new MySqlDataAdapter("SELECT ID_DISCIPLINA, DESCRIPCION_DISCIPLINA FROM t_disciplina;", cn.getCN);
                DataTable dt = new DataTable();
                da.Fill(dt);
                int filas = dt.Rows.Count;
                Disciplina[] lista = new Disciplina[filas];
                for (int i = 0; i < dt.Rows.Count; i++) {
                    lista[i] = new Disciplina();
                    lista[i].Id_Disciplina = int.Parse(dt.Rows[i]["Id_Disciplina"].ToString());
                    lista[i].Descripcion_Disciplina = dt.Rows[i]["Descripcion_Disciplina"].ToString();
                
                }
                return lista;
            }

            catch { return null; }
        }
    }
}